/*
 * Copyright @ 苏州瑞云信息技术有限公司 All rights reserved.
 */
package cn.com.recloud.bbs.controller;


import cn.com.recloud.bbs.entity.bbs_post_like_log;
import cn.com.recloud.bbs.service.PostLikeLogService;
import cn.com.recloud.bbs.vo.MyLikeVO;
import cn.com.recloud.core.util.Result;
import cn.com.recloud.one.spring.controller.BaseController;
import cn.com.recloud.one.spring.exception.OneException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author keblea xie
 * @date 2020-06-08
 */
@RestController
@RequestMapping("/api/bbs/postlikelog")
@Api(tags = "app我的点赞相关接口")
public class PostLikeLogController extends BaseController<bbs_post_like_log,PostLikeLogService> {
    @Resource
    PostLikeLogService postLikeLogService;

    @GetMapping("mylikelist")
    @ApiOperation("查询点赞列表")
    public Result myLikeList(String name,String type,
                             @RequestParam(required = false,defaultValue = "1") Integer pageIndex,
                             @RequestParam(required = false,defaultValue = "15") Integer pageSize){
        if(StringUtils.isBlank(type)){
            throw new OneException("类型不能为空");
        }
        List<MyLikeVO> list = postLikeLogService.findMyLikeList(name,type,pageIndex,pageSize);
        return new Result(list);
    }

    @PostMapping("postlike")
    @ApiOperation("收藏取消点赞")
    public Result postLike(@RequestBody bbs_post_like_log bbsPostLikeLog){
        postLikeLogService.savePostLike(bbsPostLikeLog);
        return Result.SUCCESS;
    }

}

